package com.higgins.lawapp.client.settings.components;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;
import com.higgins.lawapp.client.settings.model.DataSourceModel;


public class NameField extends DataSourceComponent	{
	private DataSourceModel dataSourceModel;
	private TextBox textBox = new TextBox();
	private DataSourceLevelDeleteButton dataSourceLevelDeleteButton;
	private Label label = new Label();
	private int tabNumber;
	
	public NameField(String fieldName, String text, DataSourceModel dataSourceModel, int tabNumber)	{
		dataSourceLevelDeleteButton = new DataSourceLevelDeleteButton(dataSourceModel, tabNumber);
	    this.dataSourceModel = dataSourceModel;
	    this.tabNumber = tabNumber;
	    textBox.setTitle(text);
	    label.setText(fieldName);
	    textBox.setText(text);
	    add(label);
	    add(textBox);
	    add(dataSourceLevelDeleteButton);
	    setWidgetLeftWidth(label, 0, Unit.PCT, 40, Unit.PCT);
	    setWidgetLeftWidth(textBox, 40, Unit.PCT, 50, Unit.PCT);
	    setWidgetRightWidth(dataSourceLevelDeleteButton, 0, Unit.PCT, 10, Unit.PCT);
//	    textBox.addKeyUpHandler(this); 
	}
	
	public String getDataSourceName()	{
		return textBox.getText();
	}

}
